package com.zhangxin.ch1;

import java.util.Scanner;

public class RangeOfNumber {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int q = scanner.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
        }
        while (q-- > 0) {
            int k = scanner.nextInt();
            findRangeOfNumber(arr, 0, arr.length - 1, k);
        }
    }

    private static void findRangeOfNumber(int[] arr, int left, int right, int number) {
        if (left > right) {
            return;
        }
        while (left < right) {
            int mid = left + right  >> 1;
            if (arr[mid] >= number) {
                right = mid;
            } else {
                left = mid + 1;
            }
        }
        if (arr[left] != number) {
            System.out.print("-1 -1");
        } else {
            System.out.print(left + " ");
            left = 0;
            right = arr.length - 1;
            while (left < right) {
                int mid = left + right + 1>> 1;
                if (arr[mid] <= number) {
                    left = mid;
                } else {
                    right = mid - 1;
                }
            }
            System.out.print(left);
        }
        System.out.println();
    }
}
